﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 自定义：防御BUFF的具体实现
/// </summary>
public class TimedDefenceBuff : TimedBuff
{
    private readonly PlayerComponent _PlayerComponent;

    private float _basefence = 80;
    private float _defenceDelta;

    public TimedDefenceBuff(ScriptableBuff buff, GameObject obj) : base(buff, obj)
    {
        _PlayerComponent = obj.GetComponent<PlayerComponent>();
    }

    protected override void ApplyEffect()
    {
        ScriptableDefenceBuff DefenceBuff = (ScriptableDefenceBuff)Buff;
        _defenceDelta = _basefence * DefenceBuff.DefenceIncrease;
        _PlayerComponent.Defence += _defenceDelta;
    }

    public override void End()
    {
        _PlayerComponent.Defence -= _defenceDelta * EffectStacks;
        EffectStacks = 0;
    }
}
